//
//  DefaultCenterView.m
//  01 微博
//
//  Created by zhoup on 16/5/16.
//  Copyright © 2016年 zhoup. All rights reserved.
//

#import "DefaultCenterView.h"


@interface DefaultCenterView()


//描述文字
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;


@property(nonatomic,strong) CADisplayLink *link;
@end

@implementation DefaultCenterView


+(instancetype)defaultCenterView
{
    return [[[NSBundle mainBundle] loadNibNamed:@"DefaultCenterView" owner:nil options:nil]lastObject];
}

-(void)setTitleImageName:(NSString *)titleImageName
{
    self.titleImageView.image = [UIImage imageNamed:titleImageName];
}

-(void)setTitleLabelName:(NSString *)titleLabelName
{
    self.titleLabel.text = titleLabelName;
}

-(CADisplayLink *)link
{
    if (!_link) {
        _link = [CADisplayLink displayLinkWithTarget:self selector:@selector(update)];
//        _link.frameInterval = 10;
    }
    return _link;
}

-(void)update
{
    self.rotateImage.transform = CGAffineTransformRotate(self.rotateImage.transform, M_PI/360);
}

-(void)startRotate
{
    // 创建定时器
    // 将定时器添加到事件循环中
    [self.link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
    
}

-(void)stopRotate
{
    // 销毁定时器
    [self.link invalidate];
    self.link = nil;
}
- (IBAction)register:(id)sender {
    
    if([self.delegate respondsToSelector:@selector(defaultCenterView:didClickLogin:)])
    {
        [self.delegate defaultCenterView:self didClickLogin:sender];
    }
}

- (IBAction)loginAction:(id)sender {
    if([self.delegate respondsToSelector:@selector(defaultCenterView:didClickRegister:)])
    {
        [self.delegate defaultCenterView:self didClickLogin:sender];
        
               
    }
}

@end
